home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWAUTODE_H
- #define FWAUTODE_H
- //========================================================================================
- //
- // File: FWAutoDe.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include <stddef.h>
-
- #ifndef FWSEXCEP_H
- #include "FWSExcep.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- #ifdef FW_USE_NEW_HELPER
- class FW_CLASS_ATTR FW_CPrivNewHelper;
- #endif
-
- //========================================================================================
- // CLASS _FW_CAutoDestructObject
- //
- // Every stack based object that must be destructed when the stack is unwound must have
- // a virtual destructor as the first item in its vtbl. This root class ensures that
- // is the case.
- //========================================================================================
-
- class FW_CLASS_ATTR _FW_CAutoDestructObject
- {
-
- public:
-
- virtual ~ _FW_CAutoDestructObject();
- // Virtual destructor. Does nothing other than reserve vtbl slot.
-
- #ifdef FW_USE_NEW_HELPER
- void* operator new(size_t size, void* p);
- void* operator new(size_t size, const FW_CPrivNewHelper &helper);
- void operator delete(void *object);
- #endif
-
- // this class needs to allocate memory in its operators new and delete. But
- // without knowing about higher-level components, how can it do this using
- // the application's heap manager? Well, you must use the next two methods to
- // set memory management hooks which then will be used to in new and delete
- static void SetOperatorNewHandler(__FW_OperatorNewHandler operatorNewHandler);
- static void SetOperatorDeleteHandler(__FW_OperatorDeleteHandler operatorDeleteHandler);
-
- static __FW_OperatorNewHandler GetOperatorNewHandler();
- static __FW_OperatorDeleteHandler GetOperatorDeleteHandler();
-
- #ifndef FW_NATIVE_EXCEPTIONS
- public: // Internal Method
-
- void __Delete();
- // Calls virtual destructor. To be used only by the exception library
-
- #endif // FW_NATIVE_EXCEPTIONS
-
- private:
- #ifdef FW_USE_NEW_HELPER
- void* operator new(size_t size) { return NULL; };
- #endif
- };
-
- #ifndef FW_NATIVE_EXCEPTIONS
-
- #ifndef __BORLANDC__
- //========================================================================================
- // CLASS _FW_CAutoDestructObject inline functions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // _FW_CAutoDestructObject::__Delete
- //----------------------------------------------------------------------------------------
- inline void _FW_CAutoDestructObject::__Delete()
- {
- #ifdef _MPWCFRONT
- // CFront is bizarre. It won't allow the unscoped destructor name, but the scoped
- // name is dispatched virtually, even though ARM says scoped names are never virtual.
- this->_FW_CAutoDestructObject::~_FW_CAutoDestructObject();
- #else
- this->~_FW_CAutoDestructObject(); // Virtual dispatch to object's destructor
- #endif
- }
- #endif
-
- #ifdef FW_USE_NEW_HELPER
- inline void* _FW_CAutoDestructObject::operator new(size_t size, void* p)
- {
- return p;
- }
- #endif
-
- #endif // FW_NATIVE_EXCEPTIONS
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-